

class KlineHandler:
    def __init__(self,  successor=None):
          self.successor = successor

    def set_successor(self, successor):
        self.successor = successor

    def handle(self, kline):
        pass  # 需要在子类中实现具体逻辑

    def compound_kline_type(self, kline,target_type):
        if "type" not in kline or kline["type"] is None:
            kline["type"]=target_type
        else:
            kline["type"]=kline["type"]+target_type
        return kline
    
    def get_kline_type(self, kline):
        type=str(kline["type"])
        rise_and_fall_type=int(type[-7])
        yin_yang_type=int(type[-6])
        shape_type=int(type[-5])
        shadow_type=int(type[-4])

        return {
            "rise_and_fall_type":rise_and_fall_type,
            "yin_yang_type":yin_yang_type,
            "shape_type":shape_type,
            "shadow_type":shadow_type
        }

